package com.mjx.algorithm;

/**
 * 简单的啤酒问题
 * 问题描述：总共6瓶酒，一瓶是脾酒，第一为顾客买走两桶葡萄酒，第二位买的葡萄酒是第一位的两倍，求啤酒
 * Created by meijingxiang on 2017/2/3.
 */
public class beer {
    public static void main(String[] args) {
        int[] jiu = {30, 32, 36, 38, 40, 62};
        for (int beer = 0; beer < jiu.length; beer++) {
            for (int wine1 = 0; wine1 != beer && wine1 < jiu.length; wine1++) {
                for (int wine2 = wine1 + 1; wine2 != beer && wine2 < jiu.length; wine2++) {
                    int custom1 = jiu[wine1] + jiu[wine2];
                    int custom2 = 0;
                    for (int i = 0; i < jiu.length; i++) {
                        if (i != beer && i != wine1 && i != wine2) {
                            custom2 += jiu[i];
                        }
                    }
                    if (custom1 * 2 == custom2) {
                        System.out.println("啤酒：" + jiu[beer]);
                        System.out.println("第一位顾客为" + jiu[wine1] + "+" + jiu[wine2] + "=" + custom1);
                        System.out.println("第二位顾客为" + custom2);
                    }
                }
            }
        }
    }
}
